package com.ruoyi.system.utils;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.domain.db.warehousestate.OrderWarehouseState;
import com.ruoyi.system.domain.dto.TradeCargoOrderDto;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

public class ConvertUtils {
    public static List<OrderWarehouseState> tradeCargoOrderDtoList2OrderWarehouseStateList(List<TradeCargoOrderDto> tradeCargoOrderDtoList, int state, Long taskId, Long warehouseId) {
        return tradeCargoOrderDtoList.stream().map(e -> {
            return tradeCargoOrderDto2OrderWarehouseState(e,state,taskId,warehouseId, SecurityUtils.getLoginUser().getUser().getUserId());
        }).collect(Collectors.toList());
    }

    public static OrderWarehouseState tradeCargoOrderDto2OrderWarehouseState(TradeCargoOrderDto tradeCargoOrderDto,int state,Long taskId,Long warehouseId,Long userId)
    {
        OrderWarehouseState orderWarehouseState = new OrderWarehouseState();
        orderWarehouseState.setOrderId(tradeCargoOrderDto.getOrderId());
        orderWarehouseState.setCreateTime(new Date());
        orderWarehouseState.setCreateBy(userId);
        orderWarehouseState.setWarehouseId(warehouseId);
        orderWarehouseState.setState(state);
        orderWarehouseState.setTaskId(taskId);
        return orderWarehouseState;
    }
}
